package nbranch.tree.maxdepth;

import nbranch.tree.perorder.Node;

/**
 * @Date 2020/03/16
 * @author 王光浩
 * @Thinking 使用自下而上的递归
 */
public class MyMethodTwo {
	public int maxDepth(Node root) {
        if(root==null)return 0;
        int max=0;
        if(root.children!=null && !root.children.isEmpty()) {
        	for(Node tem:root.children)
        		max=Math.max(max, maxDepth(tem));
        }
        return max+1;
    }
}
